$(function(){
    var carInfo_datagrid,carInfo_search;
    carInfo_datagrid = $("#carInfo_datagrid");
    carInfo_search =$("#searchbtn");

    carInfo_datagrid.datagrid({
        url:'/car/list',
        fit:true,
        fitColumns:true,
        toolbar:'#datagrid_toolar',
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        columns:[[
            {field:'sn',title:'车型编码',width:60},
            {field:'carType',title:'车型分类',width:100},
            {field:'basesNumber',title:'核定载人',width:100},
            {field:'airRelease',title:'排气量',width:100},
            {field:'seatNumber',title:'座位数',width:100},
            {field:'rateDuality',title:'额定载质量(KG)',width:100},
            {field:'mainChassis',title:'车架号',width:100},
            {field:'engineNumber',title:'发动机号',width:100},
            {field:'newCarPrice',title:'新车购置价(元)',width:100},
            {field:'importation',title:'国产/进口',width:100},
            {field:'power',title:'功率',width:100}
        ]]
    });
    var cmdObj={
        //新增
        carInfo_add:function(){
            alert("add")
        },
        //编辑
        carInfo_edit:function(){

        },
        //删除
        carInfo_quit:function(){

        },
        //重新加载
        carInfo_reload:function(){

        }
    };
    //搜索
    carInfo_search.textbox({
        buttonText:'SEARCH',
        prompt:'Please Input Value',
        label:'关键字',
        labelPosition:'left',
        labelWidth:50,
        width:300,
        onClickButton:function(){
            carInfo_datagrid.datagrid("load",{
                keyword:searchbtn.val()
            });
        }
    });
    $("a[data-cmd]").on("click",function(){
        var cmd = $(this).data("cmd");
        cmdObj[cmd]();
    })
});